module CanCamel
  class GroupNode < Node
    def can?(**additional_params)
      condition.each_with_object(result.dup.merge(additional_params)) do |(method, args), result|
        args = args.symbolize_keys
        filtered = Filter.filters[method].invoke!(args: args.merge(additional_params), result: result)
        return unless filtered
        result.merge! filtered
      end || result
    end

    def rank
      3
    end
  end
end
